package kr.saeildamil.androidstudy.ch08;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

public class AnonymousHandleEvent extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View v= new View(this);
		//v.setOnTouchListener(listener);
		
		v.setOnTouchListener(new OnTouchListener(){
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					Toast.makeText(AnonymousHandleEvent.this, "Point " + event.getX() + ", " + event.getY()
									+ " ACTION_DOWN", Toast.LENGTH_SHORT).show();
					return true;
				} else if (event.getAction() == MotionEvent.ACTION_UP){
					Toast.makeText(AnonymousHandleEvent.this, "ACTION_UP", Toast.LENGTH_SHORT).show();
					return true;
				}
			 return false;
			}
		});
		setContentView(v);
	}

	
	View.OnTouchListener listener = new OnTouchListener() {
		
		public boolean onTouch(View v, MotionEvent event) {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				Toast.makeText(AnonymousHandleEvent.this, "Point " + event.getX() + ", " + event.getY()
								+ " ACTION_DOWN", Toast.LENGTH_SHORT).show();
				return true;
			} else if (event.getAction() == MotionEvent.ACTION_UP){
				Toast.makeText(AnonymousHandleEvent.this, "ACTION_UP", Toast.LENGTH_SHORT).show();
				return true;
			}
				return false;
			}
	};
 }
